<?php defined('ROOT_DIR') or die('Access denied!');?>
<!DOCTYPE HTML>
<html>
<head>
	<meta http-equiv="content-type" content="text/html" />
	<meta name="author" content="暮雨秋晨" />
	<meta charset="UTF-8" />
    <meta http-equiv="Cache-Control" content="no-cache" />
    <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1" />
    <meta name="description" content="<?php echo $config['desc'];?>" />
    <meta name="keywords" content="<?php echo $config['keywd'];?>" />
	<title><?php echo $title;?></title>
    <link rel="stylesheet" href="/Application/static/css/main.css" />
    <script src="/Application/static/js/common.js"></script>
</head>
<body>

<!-- header -->
<header>
<ul>
<li><a href="<?php echo $this->urlCreate('forum','section',array('id'=>$section['id']));?>" style="z-index: 50;"><?php echo $section['name'];?></a></li>
</ul>
</header>
<hr style="clear: both;height: 2px;margin: 0;padding: 0;" />

<!-- body -->
<div id="main">

<h1 style="text-align: center;font-size: 2em;"><?php echo $topic['title'];?></h1>
<div id="box" style="text-align: center;letter-spacing: 1px;font-size: 0.5em;">
<span style="margin-right: 0.7em;">楼主：<?php if(checkVip($user['vip'])):?><img src="/Application/static/pic/vip.png" alt="VIP" title="VIP" style="border-radius: 100%;vertical-align: top;" /><?php endif;?><b style="<?php if($user['vip']==1):?>color:red;<?php endif;?>margin: 0 2px"><?php echo $user['user'];?></b>(<?php echo $user['id'];?>)</span><span>发表时间：<?php echo dateFormat($topic['ptime']);?></span>
<span>阅读量：<?php echo $readcount;?></span>
</div>

<div id="box" style="text-indent: 2em;padding: 3px;">
<?php echo nl2br($topic['content']);?>

<?php if(!empty($uploads)):?>
<div id="box" style="text-indent: 0px;">
<p style="border-bottom: 1px solid #eee;">附件<span style="font-size: 0.7em;color: red;">(图片会自动显示)</span>：</p>
<ol style="list-style-position: inside;padding: 2px;">
<?php foreach($uploads as $upload):?>
<?php if(in_array(getExt($upload['name']),array('bmp','jpg','png','jpeg','gif'))):?>
<li style="margin: 0.5em 0px;"><img src="/<?php echo $upload['path'];?>" alt="<?php echo $upload['name'];?>" style="max-width: 100%;max-height: 100%;" /></li>
<?php else:?>
<li style="margin: 0.5em 0px;"><a href="<?php echo $this->urlCreate('download','topic',array('id'=>$upload['id']));?>"><?php echo $upload['name'];?></a></li>
<?php endif;?>
<?php endforeach;?>
</ol>
</div>
<?php endif;?>
</div>
<?php if($user['id']==$login_user['id']):?>
<!--主题发布者的操作-->
<div id="box">
<a style="margin: 0px 3px;" href="<?php echo $this->urlCreate('increase','upload',array('id'=>$topic['id']));?>">增加附件</a><a style="margin: 0px 3px;" href="<?php echo $this->urlCreate('change','topic',array('id'=>$topic['id']));?>">修改</a>
</div>
<?php endif;?>

<div id="subtitle">回复列表</div>
<div id="box">
<?php if(empty($replys)):?>
<div id="tip">没人回复？赶紧抢沙发！</div>
<?php else:?>
<ul>
<?php foreach($replys as $key=>$reply):?>
<li>
<?php if($reply['uid']==$user['id']):?>
<div style="background: url(/Application/static/pic/louzhu.png) no-repeat 100% 0;width:99%;min-height: 3em;border: 1px solid #eee;margin: 0.5em auto;padding: 1px;">
<?php else:?>
<div style="width:99%;min-height: 3em;border: 1px solid #eee;margin: 0.5em auto;padding: 1px;">
<?php endif;?>

<div style="width: 100%;border-bottom: 1px dashed #eee;">
<span><?php echo $key+1;?>楼</span>
<a href="#" style="text-decoration: none;" onclick="atUserByID('<?php echo $reply['uid'];?>');return false;">@</a><b style="<?php if(checkVipByID($reply['uid'])):?>color: red;<?php endif;?>"><?php echo $this->getUserByID($reply['uid']);?></b><span style="font-size: 0.7em;"><?php echo dateFormat($reply['ptime']);?></span>
</div>
<div style="letter-spacing: 1px;text-indent: 2em;vertical-align: middle;">
<?php echo nl2br($reply['content']);?>
</div>
</div>
</li>
<?php endforeach;?>
</ul>
<?php endif;?>
</div>

<div id="box">
<?php if($login_user):?>
<form action="<?php echo $this->urlCreate('increase','reply',array('id'=>$topic['id']));?>" method="post">
<textarea id="atuser" name="content" style="display: block;word-wrap: break-word;min-height: 80px;outline: none;padding: 3px;resize: vertical;margin: 0.5em auto;width: 97%;" placeholder="回复"></textarea>
<input type="submit" name="submit" value="回复" style="display: block;width: 6em;margin: 6px auto;height: 3em;" />
</form>
<?php else:?>

<p style="color: #EE7700;text-align: center;">您未登录，无权回复。请<a href="<?php echo $this->urlCreate('user','login');?>">登录</a>/<a href="<?php echo $this->urlCreate('user','register');?>">注册</a>后回复。</p>

<?php endif;?>
</div>
</div>
</div>

<!-- footer -->
<footer>
&copy;<a href="http://www.doubear.com">Doubear</a> Driven by <a href="http://www.domvc.com">DoMVC</a> framework
</footer>

</body>
</html>